package com.taomu.app.zongchouhuli.utils.dialog;

import android.app.Dialog;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.DialogFragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.taomu.app.zongchouhuli.R;
import com.taomu.app.zongchouhuli.utils.DpUtils;
import com.taomu.app.zongchouhuli.utils.adpter.SelectBankAdp;
import com.taomu.app.zongchouhuli.utils.entity.SelectBankEntity;

import java.util.List;

public class SelectQQDialog extends DialogFragment {
    private LinearLayout mWxLin;

    private LinearLayout mQQLin;

    private TextView mCancleTv;

    private View view;

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        view = inflater.inflate(R.layout.dialog_share_qqwx, container, false);
        return view;
    }

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        initView();
        initData();
        initEvent();
    }

    private void initView(){
        mWxLin = view.findViewById(R.id.dialog_share_wx);
        mQQLin = view.findViewById(R.id.dialog_share_qq);
        mCancleTv = view.findViewById(R.id.dialog_share_close);
    }

    private List<SelectBankEntity> mData;

    private SelectBankEntity selectData;

    private void initData(){

    }

    private void initEvent(){
        mWxLin.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(listener != null){
                    listener.onItemClick("wx");
                }
            }
        });
        mQQLin.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(listener != null){
                    listener.onItemClick("qq");
                }
            }
        });
        mCancleTv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
    }

    @NonNull
    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        this.setStyle(STYLE_NORMAL, R.style.bottom_up_dialog);
        Dialog dialog = super.onCreateDialog(savedInstanceState);
        Window dialogWindow = dialog.getWindow();
        WindowManager.LayoutParams lp = dialogWindow.getAttributes();
        lp.width = DpUtils.screnWidth();
        //todo:需要改成银行卡数量加1
        lp.height = DpUtils.dp2px(72+36+1);
        dialogWindow.getDecorView().setPadding(0, 0, 0, 0);
        dialogWindow.setGravity(Gravity.BOTTOM);
        dialogWindow.setAttributes(lp);
        return dialog;
    }


    private SelectShareListener listener;

    public void setSelectShareListener(SelectShareListener listener){
        this.listener = listener;
    }

    public interface SelectShareListener{
        void onItemClick(String type);
    }
}
